package cn.dqy.gotanserver.support;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class EmailSupport {
    static Logger logger = LoggerFactory.getLogger(EmailSupport.class);

    //注入邮件工具类
    @Autowired
    private JavaMailSender javaMailSender;

    @Value("${spring.mail.username}")
    private String sendMailer;

    public void sendSimpleMail(String content){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(sendMailer);
        message.setFrom(sendMailer);
        message.setSubject("通知");
        message.setText(content);
        javaMailSender.send(message);
        logger.info("通知邮件成功");
    }
}
